import requestProxy from '@/utils/request';

const { request } = requestProxy;
// 获取报表列表
export function getReportList(params) {
  return request({
    url: '/admin/report/list',
    method: 'get',
    params
  });
}
// 获取表格列表
export function getSheetList(params) {
  return request({
    url: '/admin/report/sheet/list',
    method: 'get',
    params
  });
}
// 获取报表详情
export function getDetailData(params) {
  return request({
    url: `admin/report/list/detail/${params.id}`,
    method: 'get',
    params
  });
}

// 获取报表分类
export function getReportCategory(params) {
  return request({
    url: '/admin/report/category/list',
    method: 'get',
    params
  });
}

// 删除报表
export function deleteReport(id) {
  return request({
    url: '/admin/report/list/delete/' + id,
    method: 'post'
  });
}

// 置顶报表
export function stickReport(id, data) {
  return request({
    url: '/admin/report/list/stick/' + id,
    method: 'post',
    data
  });
}

// 字段列表
export function getFieldList(params) {
  return request({
    url: '/admin/field/list',
    method: 'get',
    params
  });
}

// 获取字段来源报表接口
export function getfieldSource(data) {
  return request({
    url: '/admin/report/fieldSource',
    method: 'post',
    data
  });
}

// 临时字段保存
export function saveTempReport(data) {
  return request({
    url: '/admin/report/importTempReport/save',
    method: 'post',
    data
  });
}

// 新建汇总报表
export function createCollectReport(data) {
  return request({
    url: '/admin/report/create/collect',
    method: 'post',
    data
  });
}
// 编辑汇总报表
export function editCollectReport(data) {
  return request({
    url: '/admin/report/edit/collect',
    method: 'put',
    data
  });
}

// 新建基础报表
export function createBaseReport(data) {
  return request({
    url: '/admin/report/list/create',
    method: 'post',
    data
  });
}
// 编辑基础报表
export function editBaseReport(data) {
  return request({
    url: '/admin/report/list/edit',
    method: 'put',
    data
  });
}

// 获取图表列表
export function getChartList(params) {
  return request({
    url: '/admin/report/list/chart',
    method: 'get',
    params
  });
}
// 新建图表
export function createChart(data) {
  return request({
    url: '/admin/report/list/chart/create',
    method: 'post',
    data
  });
}
// 编辑图表
export function editChart(data) {
  return request({
    url: '/admin/report/list/chart/edit',
    method: 'post',
    data
  });
}

// 获取图表详情（编辑用）
export function getChartEdit(params) {
  return request({
    url: '/admin/report/list/chart/detail',
    method: 'get',
    params
  });
}
// 获取图表数据（查看图表用）
export function getChartData(params) {
  return request({
    url: '/admin/report/list/chart/show',
    method: 'get',
    params
  });
}

// 删除图表
export function deleteChart(id) {
  return request({
    url: `admin/report/list/chart/delete/${id}`,
    method: 'post'
  });
}
// 表格数据展示
// 获取指定文件指定tab文件
export function getFileData(id, params, cancelToken) {
  return request({
    url: `/admin/report/file/${id}/data`,
    method: 'post',
    data: params,
    cancelToken
  });
}
// 获取文件tab列表
export function getFileTabs(id) {
  return request({
    url: `/admin/report/file/${id}/tabs`,
    method: 'get'
  });
}
// 获取指定文件指定tab文件列表表头的筛选值
export function getFileTitleList(id, params, cancelToken) {
  return request({
    url: `/admin/report/file/${id}/titles/data`,
    method: 'post',
    data: params,
    cancelToken
  });
}
export function getOptions() {
  return request({
    url: '/admin/report/create/collect/options',
    method: 'get'
  });
}

export function getOptionsData(params) {
  return request({
    url: '/admin/report/create/collect/options/data',
    method: 'get',
    params
  });
}
// 统计图表-获取数据表
export function getDataTable(params) {
  return request({
    url: '/admin/report/dataTable',
    method: 'get',
    params
  });
}

// 统计图表-新增图表
export function createChartTable(data) {
  return request({
    url: '/admin/charts/add',
    method: 'post',
    data
  });
}

// 统计图表-批量新增图表
export function batchCreateChartTable(data) {
  return request({
    url: '/admin/charts/batch/add',
    method: 'post',
    data
  });
}

// 统计图表-编辑图表
export function editChartTable(data) {
  return request({
    url: '/admin/charts/edit/' + data.id,
    method: 'post',
    data
  });
}
// 图表列表
export function getChartTableList(params) {
  return request({
    url: '/admin/charts/statistics/chart',
    method: 'get',
    params
  });
}

// 统计图表-详情
export function getChartTableDetail(data) {
  return request({
    url: '/admin/charts/detail/' + data.id,
    method: 'post',
    data
  });
}
// 统计图表-详情
export function removeChartTable(data) {
  return request({
    url: '/admin/charts/delete',
    method: 'delete',
    data
  });
}

// 统计图表-详情清空图表
export function clearCharts(id) {
  return request({
    url: '/admin/charts/clear/' + id,
    method: 'delete'
  });
}

// 统计图表-编辑统计页面模块配置
export function editChartTableLayout(data) {
  return request({
    url: '/admin/charts/page/config/edit',
    method: 'put',
    data
  });
}

// 统计图表-图表列表
export function getChartTableLayout(params) {
  return request({
    url: '/admin/charts/statistics/chart',
    method: 'get',
    params
  });
}
// 统计图表编辑-详情
export function chartDetail(data) {
  return request({
    url: '/admin/charts/detail/' + data.id,
    method: 'post',
    data
  });
}

export function setChartConfig(data) {
  return request({
    url: '/admin/charts/config/edit',
    method: 'put',
    data
  });
}
export function getChartConfig(params) {
  return request({
    url: '/admin/charts/config',
    method: 'get',
    params
  });
}

export function getChartTab(params) {
  return request({
    url: '/admin/charts/tab/list',
    method: 'get',
    params
  });
}

export function updateData(params) {
  return request({
    url: '/admin/report/maintainSystemDataToMongodb',
    method: 'get',
    params
  });
}
// 【v2.8.9】新接口，用来根据关联字段获取报表，使用范围：统计图表的表格模块和概览标签模块
/**
 * @param {number} requireField 关联字段的id
 * @param {string} reportName 报表名称，用于搜索
 */
export function getReportFilter(params) {
  return request({
    url: '/admin/report/list/filter',
    method: 'get',
    params
  });
}
/**
 * @param {number} reportId 报表id
 */
export function getReportField(params) {
  return request({
    url: '/admin/report/field/list',
    method: 'get',
    params
  });
}

// 获取全局筛选项
export function getGlobalFilter(params) {
  return request({
    url: '/admin/charts/global/filter',
    method: 'get',
    params
  });
}
// 设置全局筛选项
export function setGlobalFilter(data) {
  return request({
    url: '/admin/charts/set/global/filter',
    method: 'post',
    data
  });
}

// 图表颜色主题
export function getChartColor() {
  return request({
    url: '/admin/charts/color',
    method: 'get'
  });
}
export function addChartColor(data) {
  return request({
    url: '/admin/charts/color/add',
    method: 'post',
    data
  });
}
export function editChartColor(data) {
  return request({
    url: '/admin/charts/color/edit/' + data.id,
    method: 'put',
    data
  });
}
export function deleteChartColor(data) {
  return request({
    url: '/admin/charts/color/delete/' + data.id,
    method: 'delete'
  });
}
